package com.sphd.beautysalon.presenter;


import com.android.volley.VolleyError;
import com.sphd.beautysalon.info.GreensInfo;
import com.sphd.beautysalon.model.FoodMenuModelImpl;
import com.sphd.beautysalon.view.FoodMenuView;

import java.util.List;

/**
* Created by Hu on 2016/11/16
*/

public class FoodMenuPresenterImpl implements FoodMenuPresenter{
    FoodMenuModelImpl foodMenuModel;
    FoodMenuView foodMenuView;

    public FoodMenuPresenterImpl(FoodMenuView foodMenuView) {
        this.foodMenuView = foodMenuView;
        foodMenuModel=new FoodMenuModelImpl();
    }

    @Override
    public void addData(String url) {
        foodMenuView.showLoading();
            foodMenuModel.sendUrl(url,this);
    }

    @Override
    public void sendError(VolleyError error) {
    foodMenuView.dissLoading();
    }

    @Override
    public void sendRes(List<GreensInfo> greensInfos) {
        foodMenuView.recRes(greensInfos);
        foodMenuView.dissLoading();
    }

    @Override
    public void delItem(String s) {
        foodMenuView.showLoading();
        foodMenuModel.sendDelUrl(s,this);
    }

    @Override
    public void sendRes(int res) {
        if (res==1){
            foodMenuView.delSucced();
        }else {
            foodMenuView.delError();
        }
        foodMenuView.dissLoading();
    }
}